import 'package:flutter/material.dart';
import 'package:flutter_audit_app/res/colors.dart';
import 'package:flutter_audit_app/res/gaps.dart';
import 'package:flutter_audit_app/widgets/header_text.dart';

///  项目名称：flutter_audit_app
///  Created by leon on 2020/10/21 .

///  list_view_header_model
///
class ListViewHeaderModel {
  String _title;
  int _weight;
  double _width;

  ListViewHeaderModel({String title, int weight = 1, double width})
      : _title = title,
        _weight = weight,
        _width = width;
}

Widget _listViewHeaderWeight(ListViewHeaderModel model) {
  return Expanded(
    flex: model._weight,
    child: Stack(
      children: [
        Align(child: HeaderText(model._title)),
        Align(
          alignment: Alignment.centerLeft,
          child: Gaps.hLine,
        ),
      ],
    ),
  );
}

Widget listViewHeader({
  double h = 30,
  Color color = Colours.u_bbd4ee,
  List<ListViewHeaderModel> list,
}) {
  List<Widget> childrenList = [];
  childrenList.addAll(
      list.map((e) => _listViewHeaderWeight(e)).toList()..add(Gaps.hLine));
  return Container(
    color: color,
    height: h,
    child: Row(children: childrenList),
  );
}
